import 'package:flutter/material.dart';
import 'package:flutter_framework/repository/home_api.dart';
import 'package:flutter_framework/utils/http/base_url_config.dart';
import 'package:flutter_framework/utils/http/dio_utils.dart';
import 'package:flutter_framework/utils/http/model/result_model.dart';
import 'package:flutter_framework/utils/logs.dart';
import 'package:flutter_framework/views/test_network/client/test_network_client.dart';

import '../../repository/model/home_data_item.dart';

class TestNetwork extends StatefulWidget {
  @override
  TestNetworkState createState() => TestNetworkState();
}

class TestNetworkState extends State<TestNetwork> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('网络请求测试'),
        ),
        body: Column(
          children: [
            ListTile(
              onTap: () async {
                dynamic _res = await TestNetworkClient.acquire.getTasks();
                logs(_res);
              },
              leading: const Icon(
                Icons.network_check,
              ),
              title: const Text('测试网络请求数据'),
            ),
            const Divider(
              color: Colors.grey,
            ),
            ListTile(
              onTap: () async {
                try {
                  var _res = await HomeApi.getHomeData();
                  logs('数据转换: ${_res.data.page}');
                } catch (e) {}
              },
              leading: const Icon(
                Icons.network_check,
              ),
              title: const Text('测试原生DIO网络请求数据'),
            ),
          ],
        ));
  }
}
